#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "cJSON.h"

int gaia_parse_json(char *json_string);
int main(void)
{
  //char * json1 = "{\"id\":1, \"nodeId\":11, \"deviceId\":111, \"deviceName\":\"aaa\"}";
  char *json1 = "{\"city\":\"Beijing\",\"street\":\" Chaoyang Road \",\"postcode\":100025}";
  gaia_parse_json(json1);
  return 0;
}

int gaia_parse_json(char *json_string)
{
  cJSON *root;
  cJSON *format;
  int value_int;
  int value_test_int;
  char *value_string = NULL;

  root = cJSON_Parse(json_string);
  value_int = cJSON_GetObjectItem(root,"postcode")->valueint;
  //value_test_int = cJSON_GetObjectItem(root,"uplooking")->valueint;
  value_string = cJSON_GetObjectItem(root,"city")->valuestring;


  if(!value_test_int)
    fprintf(stderr,"object uplooking is not exits!\n");

  printf("%d\n",value_int);
  printf("%s\n",value_string);

  cJSON_Delete(root);
  return 0;
}
